#include <iostream>

using namespace std;

const int N = 15;
int a[N][N];
int f[N][N];

int n, m;

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            char ch; cin >> ch;
            if(ch == '0') a[i][j] = -1;
            else a[i][j] = 1;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + a[i][j];
        }
    }
    for(int len = 15; len >= 2; len--)
    {
        for(int x1 = 1; x1 + len - 1 <= n; x1++)
        {
            for(int y1 = 1; y1 + len - 1 <= m; y1++)
            {
                int x2 = x1 + len - 1;
                int y2 = y1 + len - 1;
                int t = 
                if(t == 0)
                {
                    cout << len * len << endl;
                    return 0;
                }
            }
        }
    }
//    cout << f[3][5] <<" " << f[1][2] << endl;
    cout << 0 << endl;
    return 0;
}
